Skip to content

Conversation

@Arunodoy18
Copy link

Description

The debug exporter was rendering TraceID and SpanID using logEntry, which caused
misaligned output compared to other fields rendered as attributes.

This change updates the debug exporter to render TraceID and SpanID using
logAttr, ensuring consistent formatting and column alignment with the rest
of the log output.

Link to tracking issue

Fixes #14471

Testing

  • Updated golden testdata to reflect the corrected output format
  • Ran go test ./...
  • Ran go build ./...

Documentation

No documentation changes were required.

@Arunodoy18 Arunodoy18 requested review from a team and andrzej-stencel as code owners January 27, 2026 20:22
@Arunodoy18 Arunodoy18 requested a review from codeboten January 27, 2026 20:22
@github-actions github-actions bot added the exporter/debug Issues related to the Debug exporter label Jan 27, 2026
@Arunodoy18
Copy link
Author

I cleaned up the branch, removed duplicated diffs, and force-pushed a single clean commit.
The fix now renders TraceID and SpanID consistently as attributes, and testdata has been updated.

Thanks for the review.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.82%. Comparing base (15a4484) to head (4fc64ae).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14489      +/-   ##
==========================================
- Coverage   91.84%   91.82%   -0.03%     
==========================================
  Files         677      677              
  Lines       42699    42699              
==========================================
- Hits        39219    39210       -9     
- Misses       2425     2431       +6     
- Partials     1055     1058       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@andrzej-stencel andrzej-stencel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request tries to make the same change as #14472, which I rejected as incorrect. What is the reason for this PR?

@Arunodoy18
Copy link
Author

Thanks for pointing this out.

I wasn’t aware that #14472 was rejected for functional reasons.
My intent here was to address #14471 by making the TraceID and SpanID rendering consistent with other attributes, but I may be missing the design constraint that made the previous change incorrect.

Could you clarify what aspect of this approach is not desired, or what the correct direction should be for #14471?
I’m happy to adjust or close this PR accordingly.

@andrzej-stencel
Copy link
Member

My intent here was to address #14471

I think you meant #13207 and not #14471?

As pointed out in my comments on the previous PR #14472 (review) and on the original issue #13207 (comment), I believe there's nothing to fix, current behavior is correct. TraceID and SpanID are fields of the LogRecord, not attributes, that's why they are output by the Debug exporter with the logEntry method, just like other log record fields like Timestamp or Severity.

@andrzej-stencel
Copy link
Member

After writing the above comment, I took a closer look and noticed that while the log record rendering in Debug exporter uses the logEntry method for log fields, it's actually different for spans - the fields of a span are rendered using the logAttr method. This makes the output different between logs and traces/spans:

Logs - log fields are not indented:

Logs    {"resource logs": 1, "log records": 1}
ResourceLog #0
Resource SchemaURL: https://opentelemetry.io/schemas/1.25.0
Resource attributes:
     -> service.name: Str(telemetrygen)
ScopeLogs #0
ScopeLogs SchemaURL: 
InstrumentationScope  
LogRecord #0
ObservedTimestamp: 1970-01-01 00:00:00 +0000 UTC
Timestamp: 2026-01-29 11:10:22.325817 +0000 UTC
SeverityText: Info
SeverityNumber: Info(9)
Body: Str(the message)
Attributes:
     -> app: Str(server)
Trace ID: 
Span ID: 
Flags: 0

Traces - span fields are indented:

Traces  {"resource spans": 1, "spans": 2}
ResourceSpans #0
Resource SchemaURL: https://opentelemetry.io/schemas/1.25.0
Resource attributes:
     -> service.name: Str(telemetrygen)
ScopeSpans #0
ScopeSpans SchemaURL: 
InstrumentationScope telemetrygen 
Span #0
    Trace ID       : 7d2763b32e70fcbc74eae972eca5c3fb
    Parent ID      : fa600bbfc591d824
    ID             : 35d7e0fa55c783d3
    Name           : okey-dokey-0
    Kind           : Server
    Start time     : 2026-01-29 11:10:37.810223 +0000 UTC
    End time       : 2026-01-29 11:10:37.810346 +0000 UTC
    Status code    : Unset
    Status message : 
    DroppedAttributesCount: 0
    DroppedEventsCount: 0
    DroppedLinksCount: 0
Attributes:
     -> net.sock.peer.addr: Str(1.2.3.4)
     -> peer.service: Str(telemetrygen-client)

This is an inconsistency in the detailed output of the Debug exporter.

For completeness, here's output of metrics (no indentation):

Metrics {"resource metrics": 1, "metrics": 1, "data points": 1}
ResourceMetrics #0
Resource SchemaURL: https://opentelemetry.io/schemas/1.13.0
Resource attributes:
     -> service.name: Str(telemetrygen)
ScopeMetrics #0
ScopeMetrics SchemaURL: 
InstrumentationScope  
Metric #0
Descriptor:
     -> Name: gen
     -> Description: 
     -> Unit: 
     -> DataType: Gauge
NumberDataPoints #0
StartTimestamp: 1970-01-01 00:00:00 +0000 UTC
Timestamp: 2026-01-29 11:10:31.569929 +0000 UTC
Value: 0

I didn't check profiles, because telemetrygen does not support profiles yet if I'm not mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

exporter/debug Issues related to the Debug exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants